Learn how to *install MongoDB Community Server**, along with **mongo Shell* and **MongoDB Compass**, on Ubuntu 24.04 LTS. MongoDB is a leading NoSQL database widely used for modern application development. This step-by-step guide walks you through installing and configuring MongoDB, running queries with mongo Shell, and using MongoDB Compass for a graphical interface to manage your data. <br /><br />--- <br /><br />What You’ll Learn: <br />1. Installing MongoDB Community Server on Ubuntu 24.04. <br />2. Configuring mongo Shell for command-line operations. <br />3. Setting up and using MongoDB Compass for GUI-based database management. <br /><br />--- <br /><br />Steps to Install MongoDB <br /><br />#### 1. *Update System Packages* <br />Keep your system up-to-date: <br />```bash <br />sudo apt update && sudo apt upgrade -y <br />``` <br /><br />#### 2. *Import MongoDB GPG Key* <br />Add MongoDB's official GPG key to verify packages: <br />```bash <br />``` <br /><br />#### 3. *Add the MongoDB Repository* <br />Add the MongoDB Community repository to your sources list: <br />```bash <br />``` <br /><br />#### 4. *Install MongoDB* <br />Update the package list and install MongoDB: <br />```bash <br />sudo apt update <br />sudo apt install mongodb-org -y <br />``` <br /><br />#### 5. *Start and Enable MongoDB Service* <br />Ensure MongoDB starts and is enabled on boot: <br />```bash <br />sudo systemctl start mongod <br />sudo systemctl enable mongod <br />``` <br /><br />#### 6. *Verify Installation* <br />Check the MongoDB version to confirm the installation: <br />```bash <br />mongod --version <br />``` <br /><br />--- <br /><br />Install mongo Shell <br /><br />The mongo Shell is included with the `mongodb-org` package. You can access it by running: <br />```bash <br />mongosh <br />``` <br />Use it to interact with your databases directly via the terminal. <br /><br />--- <br /><br />Steps to Install MongoDB Compass <br /><br />#### 1. *Download MongoDB Compass* <br /><br />#### 2. *Install MongoDB Compass* <br />Use the following command to install the `.deb` file: <br />```bash <br />sudo dpkg -i mongodb-compass*.deb <br />``` <br /><br />#### 3. *Launch MongoDB Compass* <br />Run MongoDB Compass from the application menu or using: <br />```bash <br />mongodb-compass <br />``` <br /><br />#### 4. *Connect to MongoDB Server* <br />Launch MongoDB Compass. <br />Use `localhost:27017` as the connection string to connect to your MongoDB instance. <br /><br />--- <br /><br />Test MongoDB Installation <br />1. Open *mongo Shell* and run: <br /> ```bash <br /> show dbs <br /> ``` <br /> This lists the available databases. <br />2. Create a new database: <br /> ```bash <br /> use testdb <br /> ``` <br />3. Add a sample document: <br /> ```javascript <br /> db.testcollection.insertOne({ name: "MongoDB", type: "NoSQL" }) <br /> ``` <br /><br />--- <br /><br />Why Use MongoDB, mongo Shell, and MongoDB Compass? <br />**MongoDB**: Fast and scalable NoSQL database for modern applications. <br />**mongo Shell**: Command-line tool for developers to interact with data. <br />**MongoDB Compass**: User-friendly GUI for managing MongoDB visually. <br /><br />Follow these steps to set up a powerful database system on Ubuntu 24.04. Like, share, and subscribe for more tutorials!